#ifndef Dialog_H
#define Dialog_H

#include <QDialog>
#include <QModelIndex>
#include <QTimeEdit>

#include <qwt_plot_renderer.h>
#include <qwt_plot_canvas.h>
#include <qwt_plot_multi_barchart.h>
#include <qwt_column_symbol.h>
#include <qwt_plot_layout.h>
#include <qwt_legend.h>
#include <qwt_scale_draw.h>

#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_grid.h>
#include <qwt_symbol.h>
#include <qwt_legend.h>

#include <QSqlError>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include <QSql>
#include <QMessageBox>
#include <QStringList>
#include <QString>
#include <QVector>
#include <QMap>
#include <QPainter>
#include <QPrinter>
#include <QRect>
#include <QSize>

#include <QWebView>

#include <QTranslator>

#include "modifiypassworddialog.h"
#include "adduserdialog.h"
#include "modifyuserdialog.h"
#include "logindialog.h"

#include "reportdocumentmainwindow.h"
#include "htmltable.h"
#include "def.h"
#include "splview.h"
#include "colorview.h"


namespace Ui {
class Dialog;
}

class Dialog : public QDialog
{
    Q_OBJECT

public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

    void DrawBarChartPlot(QwtPlot *plot, QString title, QVector< QVector<double> > series, int numBars);


    void DrawColorQwtPlot(QwtPlot *plot, QString cinema_hall);
    void DrawTempQwtPlot(QwtPlot *plot, QString cinema_hall);
    void DrawFtlQwtPlot(QwtPlot *plot, QString cinema_hall);
    void DrawSplQwtPlot( QString cinema_hall);
    void DrawColorAreaXy( QString cinema_hall);
    void InitPlots();
    void DrawCurve(QwtPlot *plot, QString title, QPolygonF points);
    void initDB();
    void initUI();
    void initStdTab();

    void refreshTotal();

    void clearForSetForm();
    void mod_cinema_hall();
    void add_cinema_hall();
    void refresh_model();
    void resizeEvent(QResizeEvent *e);
    void reloadCombo();
    void InitUserTableView();
    void loadTree();
    void alert(QString msg);
    void installTranslator();
    void init_email();
    void init_about();
private slots:
    void on_pushButton_13_clicked();

    void on_qry_select_cinema_hall_comboBox_currentTextChanged(const QString &arg1);

    void on_pushButton_7_clicked();



    void on_select_cinema_comboBox_currentTextChanged(const QString &arg1);

    void on_pushButton_2_clicked();

    void on_radioButton_2_clicked();

    void on_radioButton_clicked();

    void on_select_cinema_comboBox_3_currentTextChanged(const QString &arg1);

    void on_standard_select_cinema_hall_comboBox_2_currentTextChanged(const QString &arg1);
    void setNum( QLineEdit *lineEdit, double  v);
    void setLcNum(double v);
    void setRcNum(double v);
    void setCcNum(double v);
    void setHbNum(double v);
    void setLaNum(double v);
    void setRaNum(double v);
    void setTempNum(double v);
    void setCctNum(double v);
    void setWhiteFtl(double v);
    void setRedFtl(double v);
    void setGreenFtl(double v);
    void setBlueFtl(double v);


    void on_pushButton_5_clicked();

    void on_pushButton_8_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_clicked();

    void on_pushButton_6_clicked();

    void on_auto_comboBox_currentTextChanged(const QString &arg1);

    void on_pushButton_10_clicked();

    void on_AddUserpushButton_clicked();

    void on_ModifyUserpushButton_12_clicked();

    void on_loginOutpushButton_clicked();

    void on_preview_pushButton_clicked();

    void on_exit_pushButton_9_clicked();

    void on_export_pushButton_clicked();

    void on_language_comboBox_currentIndexChanged(int index);

    void on_pushButton_11_clicked();

    void on_usertableView_clicked(const QModelIndex &index);

    void on_RemoveUserpushButton_14_clicked();

    void on_select_cinema_comboBox_4_currentTextChanged(const QString &arg1);

    void on_pushButton_9_clicked();


    void on_pushButton_12_clicked();

    void on_pushButton_14_clicked();

public:
    QString username;

protected:
    void changeEvent ( QEvent * event );

private:
    Ui::Dialog *ui;
    QwtLegend *legend;
    QwtPlotCurve *curve_test;
    QwtPlotCurve *curve_std;
    QwtPlotGrid *grid;
    ModifiyPasswordDialog *modify_user_dialog;

     QwtPlotMultiBarChart *d_barChartItem;
    QwtPlotMultiBarChart *d_barChartItem_ftl;
    QwtPlotMultiBarChart *d_barChartItem_spl;
    QwtPlotMultiBarChart *d_barChartItem_other;
    QwtLegend *d_legend;
    QwtLegend *d_legend_spl;
    QwtLegend *d_legend_other;

    QwtPlotGrid *d_grid_ftl;
    QwtLegend *d_legend_ftl;
    QwtPlotCurve *d_curve_ftl_white ;
    QwtPlotCurve *d_curve_ftl_red;
    QwtPlotCurve *d_curve_ftl_green;
    QwtPlotCurve *d_curve_ftl_blue;


    QwtPlotGrid *d_grid_temp;
    QwtLegend *d_legend_temp;
    QwtPlotCurve *d_curve_temp_c ;
    QwtPlotCurve *d_curve_temp_f;


    QwtPlotGrid *d_grid_color_temp;
    QwtLegend *d_legend_color_temp;
    QwtLegend *d_legend_color_temp_std;
    QwtPlotCurve *d_curve_color_temp ;
    QwtPlotCurve *d_curve_std_color_temp;

    QwtPlotCurve *curve_demo;
    QwtLegend *legend_demo;

    SplView *splview;

    ColorView *colorview;

    ReportDocumentMainWindow *reportWindow;
    QTimeEdit *timeEdit;

    OPER_TYPE oper;
    ModifiyPasswordDialog modifyPasswordDialog;
    AddUserDialog addUserDialog;
    ModifyUserDialog modifyUserDialog;
//    LoginDialog loginDialog;
    QJsonDocument *jsonDocument;
    QTranslator translator;

    int currRow;
protected:

    QSqlQueryModel *model ;
    QSqlQueryModel *model_view;
    QSqlQueryModel *model_conf;
    QSqlQueryModel *model_temp;
    QSqlQueryModel *model_std;
    QSqlQueryModel *model_detail;
    QSqlQueryModel *model_detail_view;
    QSqlQueryModel *model_3d;
    QSqlQueryModel *model_user;
    QSqlQueryModel *model_offset;
    QSqlQueryModel *model_email;
    QSqlDatabase db;

 };

#endif // Dialog_H
